#!/bash/sh

cat >> ~/.bashrc << EOF
export RUSTUP_DIST_SERVER=https://mirrors.tuna.tsinghua.edu.cn/rustup
export RUSTUP_UPDATE_ROOT=https://mirrors.tuna.tsinghua.edu.cn/rustup/rustup
export PATH="$HOME/.cargo/bin:$PATH"
EOF

/bin/mkdir -p ~/.cargo
cat >> ~/.cargo/config << EOF
[source.crates-io]
registry = "https://code.aliyun.com/rustcc/crates.io-index"
EOF

source ~/.bashrc

curl https://sh.rustup.rs -sSf | sh

# check 
rustc --version
cargo --version
rustup --version

# if uninstall
# rustup self uninstall
